﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace nbb.darbo_grafikas
{
    public partial class FormDescribeSchedule : Form
    {
        DateTime fromDate;
        DateTime untilDate;
        public FormDescribeSchedule(DateTime from, DateTime until)
        {
            InitializeComponent();
            fromDate = from;
            untilDate = until;
            txbTitle.Text = suggestedTitle(from, until);
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txbTitle.Text.Trim()))
                return;
            Program.ScheduleId = DbCommunicator.createNewSchedule(fromDate, untilDate, txbTitle.Text, txbDescription.Text);
            this.DialogResult = DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            return;
        }

        private string suggestedTitle(DateTime from, DateTime until)
        {
            return string.Format("{0} - {1}", Program.ShortDate(from), Program.ShortDate(until));
        }
    }
}
